package com.sk.netty.udpserver;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil;

@ChannelHandler.Sharable
public class EchoUdpServerHandlerIn extends SimpleChannelInboundHandler<DatagramPacket> {
    @Override public void channelActive(ChannelHandlerContext ctx) throws Exception {
        super.channelActive(ctx);
        System.out.println("udp server");
    }

    @Override public void channelRead0(ChannelHandlerContext channelHandlerContext, DatagramPacket datagramPacket)
            throws Exception {
    System.out.println(datagramPacket.content().toString(CharsetUtil.UTF_8));
    }
}
